package com.itjiange.config;

import com.itjiange.interceptor.MyInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

/**
 * 拦截器配置类
 *
 * @author ItJiange
 * @date 2023/10/31
 */
//@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
//    @Autowired
    private MyInterceptor myInterceptor; // 拦截器

    private List<String> allowResource = List.of("/css/**", "/js/**", "/fonts/**", "/user/login",
            "/login.html", "/user/register", "/register.html", "/captcha");

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(myInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(allowResource);
    }
}
